package com.qf.controller;

import com.alibaba.fastjson.JSON;
import com.qf.entity.WeiXin;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author AzureSky_X
 * @Date 2020/11/20 9:35
 * @Version 1.0
 */
@WebServlet(name = "PayController",value = "/pay")
public class PayController extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("支付完成，回调到改地址了。。。+++++++++++++++++++++++++++++++++++++++++++++++");
        String jsonStr = request.getParameter("result");
        WeiXin weiXin = JSON.parseObject(jsonStr, WeiXin.class);
        if(weiXin.getResult().getResult_code().equals("SUCCESS")){
            System.out.println("===========================订单编号"+weiXin.getResult().getOut_trade_no());

        }

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}